use napi_derive_ohos::napi;

/// 定义地理位置结构体，映射为 JS 对象
#[napi(object)]
pub struct GeoLocation {
    pub latitude: f64,
    pub longitude: f64,
}

/// 模拟定位数据更新并处理的接口函数，接收 GeoLocation 对象
#[napi]
pub fn update_location(location: GeoLocation) {
    println!(
        "Updated location to: Latitude {}, Longitude {}",
        location.latitude, location.longitude
    );
}

/// 方便 JS 端调用快速构造 GeoLocation
#[napi]
pub fn create_location(latitude: f64, longitude: f64) -> GeoLocation {
    GeoLocation {
        latitude,
        longitude,
    }
}

